<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - gcov.info - curves/ParametersKey.h</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">curves</a> - ParametersKey.h<span style="font-size: 80%;"> (source / <a href="ParametersKey.h.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">gcov.info</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">10</td>
            <td class="headerCovTableEntry">10</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2014-06-30 01:17:31</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">2</td>
            <td class="headerCovTableEntry">2</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : /* </a>
<span class="lineNum">       2 </span>            :  * File:   ParametersKey.h
<span class="lineNum">       3 </span>            :  * Author: nichole
<span class="lineNum">       4 </span>            :  * 
<span class="lineNum">       5 </span>            :  * class to hold the identity of a set of parameters k, sigma, and mu
<span class="lineNum">       6 </span>            :  *
<span class="lineNum">       7 </span>            :  * Created on April 26, 2014
<span class="lineNum">       8 </span>            :  */
<span class="lineNum">       9 </span>            : #ifndef ALGORITHMS_CURVES_PARAMETERSKEY_H
<span class="lineNum">      10 </span>            : #define ALGORITHMS_CURVES_PARAMETERSKEY_H
<span class="lineNum">      11 </span>            : 
<span class="lineNum">      12 </span>            : #include &lt;stdint.h&gt;
<span class="lineNum">      13 </span>            : #include &lt;tr1/unordered_map&gt;
<span class="lineNum">      14 </span>            : #include &lt;string&gt;
<span class="lineNum">      15 </span>            : 
<span class="lineNum">      16 </span>            : using std::string;
<span class="lineNum">      17 </span>            : using std::tr1::unordered_map;
<span class="lineNum">      18 </span>            : 
<span class="lineNum">      19 </span>            : namespace gev {
<span class="lineNum">      20 </span>            :     
<span class="lineNum">      21 </span>            : class ParametersKey {
<span class="lineNum">      22 </span>            : 
<span class="lineNum">      23 </span>            : public:
<span class="lineNum">      24 </span>            :         
<span class="lineNum">      25 </span>            :     ParametersKey(const ParametersKey&amp;);
<span class="lineNum">      26 </span>            :     
<span class="lineNum">      27 </span>            :     ParametersKey(float k, float sigma, float mu);
<span class="lineNum">      28 </span>            :     
<span class="lineNum">      29 </span>            :     virtual ~ParametersKey();
<span class="lineNum">      30 </span>            :     
<span class="lineNum">      31 </span>            :     // For quickest implementation of determining the unique set of ParametersKey
<span class="lineNum">      32 </span>            :     // instances, code using this class will use the boost unordered_map. 
<span class="lineNum">      33 </span>            :     // The unordered_map presumably implements perfect dynamic hashing 
<span class="lineNum">      34 </span>            :     // for the keys it supports: string, wstring, float, double, long double
<span class="lineNum">      35 </span>            :     // by creating internal data structures to store collisions of items which
<span class="lineNum">      36 </span>            :     // are not the same by key_equals, but do collide because of the hash.
<span class="lineNum">      37 </span>            :     // the boost internal hash_value functions return a type of size_t, so 
<span class="lineNum">      38 </span>            :     // presumably the hash function can only provide perfect hashing (if that) 
<span class="lineNum">      39 </span>            :     // for input &lt;= 32 bit.
<span class="lineNum">      40 </span>            :     //
<span class="lineNum">      41 </span>            :     // In order to use ParametersKey as a key, I need to either convert the
<span class="lineNum">      42 </span>            :     // identity to a string, or provide a hashing function.
<span class="lineNum">      43 </span>            :     // Creating a string key is the easiest for now and allows quick testing
<span class="lineNum">      44 </span>            :     // that all values even when they collide lead to successful storage and
<span class="lineNum">      45 </span>            :     // retrieval from unordered_map for unique keys.
<span class="lineNum">      46 </span>            :     
<span class="lineNum">      47 </span>            :     // The identity for this class is k, sigma, and mu which are 32-bit floats.
<span class="lineNum">      48 </span>            :     // Those floats are converted to their 32-bit integer equivalents (IEEE 754).
<span class="lineNum">      49 </span>            :     // Then a string is created from them as unicode character code points.
<span class="lineNum">      50 </span>            :     // The char data type is usually 8 bits and string is composed of chars.
<span class="lineNum">      51 </span>            :     // So the identity of this class is 3 32-bit fields written as a 12 element 
<span class="lineNum">      52 </span>            :     // char array.
<span class="lineNum">      53 </span>            :     
<span class="lineNum">      54 </span>            :     uint32_t _floatToIntBits(float f);
<span class="lineNum">      55 </span>            :     float _intBitsToFloat(uint32_t b);
<span class="lineNum">      56 </span>            :     
<span class="lineNum">      57 </span>            :     bool isnan(float s);
<span class="lineNum">      58 </span>            : 
<span class="lineNum">      59 </span>            :     void decodeToParams(float* k, float* sigma, float* mu);
<span class="lineNum">      60 </span>            :     
<span class="lineNum">      61 </span>            :     string _getKey() const;
<span class="lineNum">      62 </span>            :     uint32_t _getKKey() const;
<span class="lineNum">      63 </span>            :     uint32_t _getSigmaKey() const;
<span class="lineNum">      64 </span>            :     uint32_t _getMuKey() const;
<span class="lineNum">      65 </span>            : 
<span class="lineNum">      66 </span>            :     bool operator==(ParametersKey &amp; other)const;
<span class="lineNum">      67 </span>            :     bool operator!=(ParametersKey &amp; other)const;
<span class="lineNum">      68 </span>            :     
<span class="lineNum">      69 </span>            :     friend bool operator==(ParametersKey const &amp; pk0, ParametersKey const &amp; pk1);
<span class="lineNum">      70 </span>            :     
<span class="lineNum">      71 </span>            :     friend bool operator!=(ParametersKey const &amp; pk0, ParametersKey const &amp; pk1);
<span class="lineNum">      72 </span>            :     
<span class="lineNum">      73 </span>            : protected:
<span class="lineNum">      74 </span>            :     
<span class="lineNum">      75 </span>            :     union int_float_bits {
<span class="lineNum">      76 </span>            :         uint32_t i;
<span class="lineNum">      77 </span>            :         float f;
<span class="lineNum">      78 </span>            :     };
<span class="lineNum">      79 </span>            :     
<span class="lineNum">      80 </span>            :     // to reduce space, could remove these and re-calculate from key upon need
<span class="lineNum">      81 </span>            :     uint32_t kKey;
<span class="lineNum">      82 </span>            :     uint32_t sigmaKey;
<span class="lineNum">      83 </span>            :     uint32_t muKey;
<span class="lineNum">      84 </span>            :     
<span class="lineNum">      85 </span>            :     void _createKey();
<span class="lineNum">      86 </span>            :     
<span class="lineNum">      87 </span>            : private:
<span class="lineNum">      88 </span>            :     
<span class="lineNum">      89 </span>            :     string key;
<span class="lineNum">      90 </span>            :     
<span class="lineNum">      91 </span>            :     void _writeIntToCharBytes(const uint32_t *readInt);
<span class="lineNum">      92 </span>            : };
<span class="lineNum">      93 </span>            : 
<span class="lineNum">      94 </span>            : } // end namespace
<span class="lineNum">      95 </span>            : 
<span class="lineNum">      96 </span>            : namespace std {
<span class="lineNum">      97 </span>            :     namespace tr1 {
<a name="98"><span class="lineNum">      98 </span>            :         template&lt;&gt; struct hash&lt;gev::ParametersKey&gt;</a>
<span class="lineNum">      99 </span>            :         : public std::unary_function&lt;gev::ParametersKey, std::size_t&gt; {
<span class="lineNum">     100 </span><span class="lineCov">    2320665 :             std::size_t operator()(const gev::ParametersKey &amp;pk) const {</span>
<span class="lineNum">     101 </span><span class="lineCov">    2320665 :                 string tmp = pk._getKey();</span>
<span class="lineNum">     102 </span><span class="lineCov">    2320665 :                 return hash&lt;string&gt;()(tmp);</span>
<span class="lineNum">     103 </span><span class="lineCov">    2320665 :             }</span>
<span class="lineNum">     104 </span>            :         };
<span class="lineNum">     105 </span>            :     }
<a name="106"><span class="lineNum">     106 </span>            :     </a>
<span class="lineNum">     107 </span>            :     template&lt;&gt; struct equal_to&lt;gev::ParametersKey&gt; {
<span class="lineNum">     108 </span><span class="lineCov">    1188855 :         bool operator()(const gev::ParametersKey&amp; pk0, const gev::ParametersKey&amp; pk1) const {</span>
<span class="lineNum">     109 </span><span class="lineCov">    2229885 :             if (pk0._getKKey() != pk1._getKKey()) { return false; }</span>
<span class="lineNum">     110 </span><span class="lineCov">     158424 :             if (pk0._getSigmaKey() != pk1._getSigmaKey()) { return false; }</span>
<span class="lineNum">     111 </span><span class="lineCov">     137607 :             if (pk0._getMuKey() != pk1._getMuKey()) { return false; }</span>
<span class="lineNum">     112 </span><span class="lineCov">     136845 :             return true;</span>
<span class="lineNum">     113 </span><span class="lineCov">    1188855 :         }</span>
<span class="lineNum">     114 </span>            :     };
<span class="lineNum">     115 </span>            :     
<span class="lineNum">     116 </span>            : }
<span class="lineNum">     117 </span>            : #endif
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.11</a></td></tr>
  </table>
  <br>

</body>
</html>
